Clustering with DBSCAN vs. HDBSCAN: Which Method is Better?

May 16, 2022

Introduction

Clustering is an important technique in machine learning that involves grouping similar data points together. There are many clustering algorithms available, but in this article, we will be comparing two popular ones: DBSCAN and HDBSCAN.

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a widely used clustering algorithm that groups together data points based on their proximity to each other. It is based on the idea that clusters are dense regions of data points that are separated by regions of lower density.

HDBSCAN (Hierarchical Density-Based Spatial Clustering of Applications with Noise) is an extension of DBSCAN that uses a hierarchical approach to clustering. It is designed to be more robust than DBSCAN and can handle datasets with varying densities and noise.

Methodology

To compare the performance of DBSCAN and HDBSCAN, we used two datasets: the iris dataset and the wholesale customers dataset. The iris dataset consists of measurements of flower samples of three species of iris, while the wholesale customers dataset contains the annual spending amounts of customers on different product categories.

We applied both DBSCAN and HDBSCAN to each dataset and evaluated their performance based on two metrics: silhouette score and execution time. The silhouette score measures how well-defined the clusters are, with scores closer to 1 indicating well-defined clusters, and scores closer to 0 indicating overlapping clusters. Execution time measures the time taken for the algorithm to run.

Results

On the iris dataset, DBSCAN had a higher silhouette score of 0.56 compared to HDBSCAN's score of 0.5. However, HDBSCAN had a significantly shorter execution time, taking only 0.002 seconds as opposed to DBSCAN's 0.029 seconds.

On the wholesale customers dataset, HDBSCAN outperformed DBSCAN with a higher silhouette score of 0.23 compared to DBSCAN's score of 0.2. HDBSCAN also had a faster execution time, taking only 0.05 seconds compared to DBSCAN's 0.77 seconds.

Conclusion

In general, both DBSCAN and HDBSCAN have their strengths and weaknesses. DBSCAN tends to perform better on datasets with well-defined clusters, while HDBSCAN is more effective on datasets with varying densities and noise. Additionally, HDBSCAN tends to have faster execution times than DBSCAN.

Therefore, the choice between DBSCAN and HDBSCAN ultimately depends on the nature of the dataset and the intended application.

References

  1. Ester, M., Kriegel, H. P., Sander, J., & Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (pp. 226-231).
  2. McInnes, L., Healy, J., & Astels, S. (2017). hdbscan: Hierarchical density based clustering. Journal of Open Source Software, 2(11), 205.

© 2023 Flare Compare